//导入mars3d主库
import * as mars3d from 'mars3d'
import { Cesium } from "mars3d";
import { CesiumRoleController } from "./CesiumRoleController.js"

export let thisMap  // 地球模型

// 恢复初始化地球模型
export const resetCommonMap = () => {

}


let controller
// 初始地球模型
export const initMap = (val) => {

  thisMap = val
  controller = new CesiumRoleController(mars3d.Cesium, thisMap.viewer)
  thisMap.setCursor("crosshair")
  thisMap.once("click", (event) => {
    thisMap.setCursor("default")
    initController(event.cartesian)
  })

}



function initController (position) {
  const point = mars3d.LngLatPoint.fromCartesian(position) // 转为经纬度
  controller.init({
    position: [point.lng, point.lat, point.alt],
    url: "/model/arrow.gltf",
    animation: "",
    lockViewLevel: 1,
    pitch: -25,
    speed: 2,
    range: 300.0
  })
}
